import {produce} from 'immer';

/**
 * 续班看板，关联过滤器
 * @author caohuayu@baijia.com
 * @date 2020-11-20
 */
const initialState = {
    // 小组过滤器
    smallFilter: [],
    // 个人过滤器
    personalFilter: []
};

export default {
    state: {
        ...initialState
    },

    action: {
        reset(payload) {
            return payload;
        },
        setFilter(payload) {
            return payload;
        },
    },

    reducer: {
        reset() {
            return {
                ...initialState
            };
        },
        setFilter(state, action) {
            const {payload} = action;
            const nextState = produce(state, draft => {
                draft[payload.filterName] = payload.data;
            });
            return nextState;
        }
    }
};
